import { http } from "@/utils/http";
import type { R } from "@/types/api";

export interface UserInfoVO {
  userId: number;
  email: string;
  nickname: string;
  avatar: string;
}

// 获取用户信息
export function getUserInfo() {
  return http.get<R<UserInfoVO>>("/user/info");
}

// 登录
export function login(data: { email: string; password: string; captchaCode: string }) {
  return http.post<R<UserInfoVO>>("/users/login", data);
}

// 注册
export function register(data: {
  email: string;
  password: string;
  nickname?: string;
  verificationCode: string;
  captchaCode: string;
}) {
  return http.post<R<string>>("/users/register", data);
}